/*************************************************************************
 * File Name:    Remove_Element.cc
 * Author:       zero91
 * Mail:         jianzhang9102@gmail.com
 * Created Time: 2013/11/14 7:35:20
 * 
 * Description:  
 |------------------------------------------------------------------------
 | Problem: Remove Element
 |
 | Given an array and a value, remove all instances of that value in place and return the new length.
 |
 | The order of elements can be changed. It doesn't matter what you leave beyond the new length.
 |------------------------------------------------------------------------
 ************************************************************************/

#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>

using namespace std;

class Solution {
public:
    int removeElement(int A[], int n, int elem)
    {
        int ans = 0;
        
        for (int i = 0; i < n; ++i) {
            if (A[i] == elem) continue;
            A[ans++] = A[i];
        }
        return ans;
    }
};

